package com.sjc.springbootdemo.domain;

import com.sjc.springbootdemo.validator.Age;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Size;

/**
 * @Classname User
 * @Description 一个领域模型类
 * @Date 2020/4/23 14:56
 * @Created by SangJiacun
 */
public class User {

    // group分组
    public interface Save {}
    public interface Update {}

    // 更新操作的时候，要求userId必须不为空
    // 新增操作的时候，要求userId必须为空
    @Null(groups = {Save.class})
    @NotNull(groups = {Update.class})
    private Long userId;
    @Size(min = 2, max = 20, groups = {Save.class, Update.class})
    private String name;
//    @Range(min = 18, max = 70, groups = {Save.class, Update.class})
    @Age(min = 18, max = 70, groups = {Save.class, Update.class})
    private Integer age;

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }
}
